var app = angular.module('myApp', []).
  config(['$routeProvider', function($routeProvider) {
  $routeProvider.
   when('/', {templateUrl: 'invoice_search.html', controller: ListInvCtrl}).
       when('/invprnt/:invoicenumber', {templateUrl: 'invoice_search.html', controller: ListInvCtrl}).
      otherwise({redirectTo: '/'});
}]);


app.filter('startingFrom', function() 
    {
            return function(input, start) 
            {
                start = +start; //parse to int
                return input.slice(start);
            };
    });
    
function ListInvCtrl($scope, $http,$window) {
  $http.get('invoice_searchdata.php').success(function(data) 
  
  {$scope.currentPage = 0;
    $scope.pageSize = 20;
    $scope.Math = window.Math;
    $scope.invoicemast = data;
  });

   $scope.invoiceprnt = function(cust) 
   {
     //$window.alert("Report for "+cust.invoicenumber+","+ cust.custdesc + ","+ cust.invoicedate + ","+ cust.invoiceamt+ ","+ cust.DueOn+ ","+ cust.balance+ ","+ cust.invoicefile);
     //var url ="http://firstnorthglobal.com/development/invoiceappdev/report_invoice.php?custid={0}&invoicenumber={1}&invoicedate={2}&custdesc={3}&invoiceamount={4}".format("313", "131400060","1-3-2014","shetty","4444");
   var url2 = 'report_invoice.php?custid='+cust.custid+'&invoicedate='+cust.invoicedate+'&custdesc='+cust.custdesc+'&invoiceamount='+cust.invoiceamt+'&invoicenumber='+cust.invoicenumber+'&custemail='+cust.custemail+'&reporttype=Invoice';
     //window.location.href = url2;
	 window.open(url2,
	 '_blank' // <- This is what makes it open in a new window.
);
	 
  };
  
  
$scope.numberOfPages=function()
    {
        return Math.ceil($scope.data.length / $scope.pageSize);                
    };
   
   
   
}
